<template>
    <div class="person">
        <van-nav-bar title="岛屿人员" left-text="返回" left-arrow @click-left="pathGO" />
        <van-empty v-show="flat" description="岛屿无人..." />
        <van-cell-group>
            <van-cell :title="item.username" label="天青色等烟雨" v-for="item in personList" :key="item.username" />
        </van-cell-group>
    </div>
</template>

<script>
export default {
    name: "person",
    data() {
        return {
            personList: [],
            flat: true,
        };
    },
    methods: {
        getPerson() {
            if (localStorage.getItem("token")) {
                let token = JSON.parse(localStorage.getItem("token"));
                let loginUser = JSON.parse(localStorage.getItem("loginUser"));
                this.personList = token.filter((item) => {
                    return item.username != loginUser.username;
                });
                if (this.personList.length == 0) {
                    this.flat = true;
                } else {
                    this.flat = false;
                }
            }
        },
        pathGO() {
            this.$router.go(-1);
        },
    },
    created() {
        this.getPerson();
    },
};
</script>

<style lang="scss">
.person {
    height: 100vh;
    [class="van-hairline"]::after {
        border: 0;
    }
}
</style>
